[LINUX] dma: Use swiotlb mask for coherent mappings too
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Dec 2006 11:21:04 +0000 (11:21 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Dec 2006 11:21:04 +0000 (11:21 +0000)
The recent change to use a default DMA bit width of 30 bits (required
by chips like the b44) only converted the streaming DMA primitives.
The coherent mappings are still hard-coded to 31 bits.  This means
that b44 still doesn't work under Xen.

This patch makes the io_tlb_dma_bits variable global and uses it for
coherent memory mappings.

Thanks to Calvin Webster for providing a machine with a b44 and 2G
of memory I've been able to verify that this finally makes the b44
work under Xen.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Rename 'io_tlb_dma_bits' to the more correct 'dma_bits'. This also
affects the name of the boot parameter, which is now 'dma_bits='.

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h

index 5c32dd0c39a705a2dc989decce2a923bc1fbbf58..7f0538c606eec2cf797bef0b2ae12a1ff8049ed5 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/version.h>
 #include <asm/io.h>
 #include <xen/balloon.h>
+#include <asm/swiotlb.h>
 #include <asm/tlbflush.h>
 #include <asm-i386/mach-xen/asm/swiotlb.h>
 #include <asm/bug.h>
@@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
        ret = (void *)vstart;
 
        if (ret != NULL) {
-               /* NB. Hardcode 31 address bits for now: aacraid limitation. */
-               if (xen_create_contiguous_region(vstart, order, 31) != 0) {
+               if (xen_create_contiguous_region(vstart, order,
+                                                dma_bits) != 0) {
                        free_pages(vstart, order);
                        return NULL;
                }
index 4fa98132f4a5fb865259ab55bfbf817f86807755..ac2c0da536d88011bfd420b0ed019374fb0fa01f 100644 (file)
@@ -47,8 +47,8 @@ EXPORT_SYMBOL(swiotlb);
  */
 #define IO_TLB_SHIFT 11
 
-/* Width of DMA addresses in the IO TLB. 30 bits is a b44 limitation. */
-#define DEFAULT_IO_TLB_DMA_BITS 30
+/* Width of DMA addresses. 30 bits is a b44 limitation. */
+#define DEFAULT_DMA_BITS 30
 
 static int swiotlb_force;
 static char *iotlb_virt_start;
@@ -98,14 +98,14 @@ static struct phys_addr {
  */
 static DEFINE_SPINLOCK(io_tlb_lock);
 
-static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
+unsigned int dma_bits = DEFAULT_DMA_BITS;
 static int __init
-setup_io_tlb_bits(char *str)
+setup_dma_bits(char *str)
 {
-       io_tlb_dma_bits = simple_strtoul(str, NULL, 0);
+       dma_bits = simple_strtoul(str, NULL, 0);
        return 0;
 }
-__setup("swiotlb_bits=", setup_io_tlb_bits);
+__setup("dma_bits=", setup_dma_bits);
 
 static int __init
 setup_io_tlb_npages(char *str)
@@ -167,7 +167,7 @@ swiotlb_init_with_default_size (size_t default_size)
                int rc = xen_create_contiguous_region(
                        (unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
                        get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
-                       io_tlb_dma_bits);
+                       dma_bits);
                BUG_ON(rc);
        }
 
@@ -197,7 +197,7 @@ swiotlb_init_with_default_size (size_t default_size)
               bytes >> 20,
               (unsigned long)iotlb_virt_start,
               (unsigned long)iotlb_virt_start + bytes,
-              io_tlb_dma_bits);
+              dma_bits);
 }
 
 void
@@ -665,7 +665,7 @@ swiotlb_dma_mapping_error(dma_addr_t dma_addr)
 int
 swiotlb_dma_supported (struct device *hwdev, u64 mask)
 {
-       return (mask >= ((1UL << io_tlb_dma_bits) - 1));
+       return (mask >= ((1UL << dma_bits) - 1));
 }
 
 EXPORT_SYMBOL(swiotlb_init);
index 74a0c21bbecfe61793e0ffc7ec067239f5e97879..bb3d7d2416f8c58bb0ccbc97c479885d4c00bdb5 100644 (file)
@@ -34,6 +34,8 @@ extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dma_address,
 extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
 extern void swiotlb_init(void);
 
+extern unsigned int dma_bits;
+
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
 #else